<?php
class Controller extends ExtController {
	function __construct($params) {        		
        parent::__construct($params);
		$this->page = new Page(Local::get('method'), 'idn');
        $this->addTemplateData('is_sub_sub_menu', TRUE);
		$this->addChain('press-center', 'новости/пресс-центр', 'press-center/news');	
	}
	
	function news() {
		$this->addChain('news', 'новости');   
	}
	
	function _add_bar($type) {
		$SetName = $type.'set';
		$set = new $SetName(q::obj($type)->select()->where('to_bar', 1)->limit(3)->end);
		$fields = array(
                $type=>array('title', 'image')
            );
		$this->addViewData('bar_data', $set->getArray($fields));
	}
	
	function actions() {
		$this->addChain('actions', 'акции/конкурсы');   
		$params = array('id'=>'int');
        extract($this->params($params));
		if (!$id) {
	        $data = new ActionSet();
	        $fields = array(
	            'Action'=>array('date', 'short_text')
	        );
	        $this->addViewData('actions', $data->getArray($fields));
		}
		else {
			$this->_add_bar('Action');
			$action = new Action($id);
			$this->addViewData('action', $action->getFields());
			$this->view_name = '_pages/press_center/action';
		}
	}
	
	function press_release() {
		$this->addChain('press-release', 'пресс-релизы');   
		$params = array('id'=>'int');
        extract($this->params($params));
        if (!$id) {
		    $data = new PressReleaseSet();
	        $fields = array(
	            'PressRelease'=>array('date', 'short_text')
	        );
	        $this->addViewData('actions', $data->getArray($fields));
		}
        else {
        	$this->_add_bar('PressRelease');
            $obj= new PressRelease($id);
            $this->addViewData('action', $obj->getFields());
            $this->view_name = '_pages/press_center/press_release_one';
        }
	}
}
?>